<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    div {
      width: 400px;
      height: 700px;
      border: 1px solid #555;
      margin: auto;
    }
    img {
      width: 400px;
      height: 350px;
    }
    p {
      width: 400px;
      height: 130px;
      margin: auto;
      text-align: center;
      /* display: block; */
    }
    #geshu {
      width: 50px;
      height: 15px;
      border: solid 1px #666;
      display: inline-block;
    }
  </style>
  <body>
    <div>
      <img src="322520.jpg" alt="" />
      <p>皮皮虾 <br /><span>500</span></p>

      <p>
        数量: <button id="jian">-</button><span id="geshu" >0</span
        ><button id="jia">+</button>
      </p>
      <p>总价$:<span id="sum"></span></p>
    </div>

    <script>
      jian.onclick = function () {
        if (geshu.innerHTML > 0) {
            geshu.innerHTML = geshu.innerHTML - 1;
        sum.innerHTML = geshu.innerHTML * 500;
        }
        
      };
      jia.onclick = function () {
        geshu.innerHTML = geshu.innerHTML * 1 + 1;
        sum.innerHTML = geshu.innerHTML * 500;
      };
    </script>
  </body>
</html>
